﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace VietKinsNutrition.Common
{
    public class EnvInfo
    {
        public string Namhoc = null;
        public static string LopTemplate = "-1";

        public static bool LogAllowed = true;
        public SystemCls SystemConf;

        public EnvInfo()
        {
            SystemConf = new SystemCls();
        }
        public static int LogNumber = 0;
        private string _ConnectionString;

        public string ConnectionString
        {
            get { return _ConnectionString; }
            set
            {
                _ConnectionString = value;
                SystemConf = new SystemCls(this._ConnectionString);
            }
        }

        public EnvInfo(string _ConnectionString)
        {
            ConnectionString = _ConnectionString;
            SystemConf = new SystemCls(this._ConnectionString);
        }

        //public UserInfo User;
        //public EnvInfo(string _ConnectionString, UserInfo _User)
        //{
        //    ConnectionString = _ConnectionString;
        //    SystemConf = new SystemCls(this._ConnectionString);
        //    User = _User;
        //}
        public EnvInfo(EnvInfo _Env)
        {
            this.ConnectionString = _Env.ConnectionString;
            //this.User = _Env.User;
            this.SystemConf = new SystemCls(this._ConnectionString);
        }
        public static DateTime ConvertDate(DateTime tDateTime)
        {
            //DateTime NewDateTime =new System.DateTime();
            if (tDateTime != new System.DateTime())
            {
                tDateTime = new DateTime(int.Parse(tDateTime.ToString("yyyy")), int.Parse(tDateTime.ToString("MM")), int.Parse(tDateTime.ToString("dd")));
            }
            return tDateTime;
        }
        public byte[] GetPhoto(string filePath)//static
        {
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);

            byte[] photo = br.ReadBytes((int)fs.Length);

            br.Close();
            fs.Close();

            return photo;
        }

        //public EDBService DBService
        //{
        //    get
        //    {
        //        return EDBService.Sql2000;
        //    }
        //}
    }
}
